package com.controller;

import com.domain.UserFollow;
import com.dto.JsonResponse;
import com.service.UserFollowService;
import com.support.UserSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/userFollow")
@RestController
public class UserFollowApi {

    @Autowired
    private UserFollowService userFollowService;

    @Autowired
    public UserSupport userSupport;

    /**
     * 添加用户关注
     */
    @PostMapping("/addUserFollow")
    public JsonResponse<String> addUserFollow(@RequestBody UserFollow userFollow) {
        userFollowService.addUserFollow(userFollow);
        return JsonResponse.success();
    }

    /**
     * 删除用户关注
     */
    @PostMapping("/deleteUserFollow")
    public JsonResponse<String> deleteUserFollow(@RequestBody UserFollow userFollow) {
        userFollowService.deleteUserFollow(userFollow);
        return JsonResponse.success();
    }

    /**
     * 获取关注的用户列表
     */
    @GetMapping("/getUserFollow")
    public JsonResponse<List<UserFollow>> getUserFollow(Long userId) {
        List<UserFollow> result = userFollowService.getUserFollow(userId);
        return new JsonResponse<>(result);
    }

    /**
     * 获取粉丝列表
     */
    @GetMapping("/getUserFan")
    public JsonResponse<List<UserFollow>> getUserFan(Long userId) {
        List<UserFollow> result = userFollowService.getUserFans(userId);
        return new JsonResponse<>(result);
    }

}
